<div class="container">
  <div class="tabbable tabs-left" id="admin_bar">
    <%= render 'shared/admin_bar'%>
    <div class="tab-content">
      <div class="row-fluid">
        <h1 class="span12"> <%= t 'cac_don_hang'%> <% if !['da_xu_ly'].include?(params[:loc])%>
              <%= t '_da_xu_ly'%> 
              <% else %>
              <%= t '_chua_xu_ly'%> 
              <% end %> </h1>
      </div>
      
      <div class="row-fluid">
        <div class="span6">
        </div>
        <div class="span6 text-right">
          <a href="<%= url_for :loc => (params[:loc].present? ? nil : 'da_xu_ly') %>" class="btn btn-inverse"><%= params[:loc].present? ? t('chua_xu_ly') : t('da_xu_ly')%></a>
        </div>
      </div>
      
      <table class="table table-stripped don_hang">
        <thead>
          <tr>
            <th> # </th>
            <th> <%= t 'khach_hang'%> </th>
            <th> <%= t 'thoi_gian_dat_hang' %> </th>
            <th> <%= t 'dia_chi_giao_hang'%> </th>
            <th> <%= t 'dien_thoai_lien_lac'%> </th>
            <th> <%= t 'gia_tri_don_hang'%></th>
            <th> <%= t 'cap_nhat'%></th>
          </tr>
        </thead>
        <tbody>
          <% i = @index_dau_tien + 1%>
          <% for dh in @don_hangs%>
          <tr>
            <td <%= (dh.da_xu_ly ? "rowspan=2" : "")%>> <%= i%>
            <% i = i + 1%> </td>
            <td>
            	<img class="img-circle" src="<%= gravatar_url dh.nguoi_dung.email, 24 %>" />
              <%= dh.nguoi_dung.ten_hien_thi%>
            </td>
            <td>
              <%= dh.thoi_gian_dat_hang.strftime("%Y-%m-%d %H:%M:%S")%>
            </td>
            <td>
              <%= dh.dia_chi_nhan_hang %>
            </td>
            <td>
              <%= dh.dien_thoai_lien_lac %>
            </td>
            <td>
              <%= number_with_delimiter dh.tong_gia_tri, :delimiter => " "%> <span class="tien_te">VND</span>
            </td>
            <td>
              <% if !['da_xu_ly'].include?(params[:loc])%>
              <a class="btn btn-small" href="<%= url_for :action => 'cap_nhat', :uid => dh.id %>" > <%= t 'cap_nhat'%> </a>
              <% else %>
              <a class="btn btn-small"  href="<%= url_for :action => 'cap_nhat', :uid => dh.id %>"> <%= t 'cap_nhat'%> </a>
              <% end %>
            </td>
          </tr>
	<% if dh.da_xu_ly %>
	<tr class="thong_tin_xu_ly">
		<td colspan="2">
			<span><%= t 'nguoi_xu_ly'%>:</span> <%= dh.nhan_vien_xu_ly.ten_hien_thi %>
		</td>
		<td colspan="2">
			<span><%= t 'giao_hang'%>:</span> <%= dh.nhan_vien_giao_hang.ten_hien_thi %>
		</td>
		<td colspan="2">
			<span><%= t 'xu_ly_luc'%>:</span> <%= dh.updated_at.strftime("%Y-%m-%d %H:%M:%S")%>
		</td>
	</tr>
	<% end %>
          <% end %>
        </tbody>
      </table>
      <div>
        <div class="span4 pull-right">
          <div class="pager">
            <% if @co_trang_truoc %>
            <li class="previous">
              <a href="<%= url_for :loc => params[:loc], :page => @trang - 1%>">&larr; <%= t 'trang_truoc'%></a>
            </li>
            <%end %>
            <% if @co_trang_sau %>
            <li class="next">
              <a href="<%= url_for :loc => params[:loc], :page => @trang + 1%>"><%= t 'trang_sau'%> &rarr;</a>
            </li>
            <%end %>
          </div>
        </div>
        <div class="clearfix"></div>
      </div>
    </div>
  </div>
</div>
